﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media.Imaging;


namespace Vra.Components.Converters
{
	public class ImageSourceConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value == null)
				return null;
			BitmapImage logo = new BitmapImage();
			logo.BeginInit();
			string url = string.Format("pack://application:,,,/{0};component/{1}", GetType().Assembly.GetName().Name, value);
			logo.UriSource = new Uri(url);
			logo.EndInit();
			return logo;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			throw new NotImplementedException();
		}
	}
}
